import React, {useEffect, useState} from "react";
import {ScrollView, View} from "native-base";
import {StyleSheet} from "react-native";
import CutClass from "../../capsulation/cutClass";
import {NewHeader} from "../../commponents/dictionaries/newHeader";
/**
 * 故宫博物院藏印选
 * 1.故宫博物院藏古玺印选
 *
 * 战国玉玺
 * 1.古玺汇编
 *
 * 秦代印章
 * 1.风过耳堂秦印辑录
 *
 * 汉代印章
 * 1.虛無有齋摹輯漢印
 * 2.汉印精华
 *
 * 秦汉南北朝印章
 * 1.秦汉南北朝官印征存
 */
export const NewNavRight = ({datas, navigation}) => {
    let contentMap = [
        {
            name: '故宫博物院藏印选',
            content: {
                laiyuan: [],
                name: [],
                zuozhe: [],
                photo1: [],
            },
        },
        {
            name: '战国玉玺',
            content: {
                laiyuan: [],
                name: [],
                zuozhe: [],
                photo1: [],
            },
        },
        {
            name: '秦代印章',
            content: {
                laiyuan: [],
                name: [],
                zuozhe: [],
                photo1: [],
            },
        },
        {
            name: '汉代印章',
            content: {
                laiyuan: [],
                name: [],
                zuozhe: [],
                photo1: [],
            },
        },
        {
            name: '秦汉南北朝印章',
            content: {
                laiyuan: [],
                name: [],
                zuozhe: [],
                photo1: [],
            },
        },
    ];
    const [contentMaps, setContentMap] = useState([]);
    useEffect(()=>{
        if(datas.laiyuan !== undefined){
            for(let i=0;i<datas.laiyuan.length;i++){
                if(CutClass(datas.name[i])!==-1){
                    contentMap[CutClass(datas.name[i])].content.laiyuan.push(datas.laiyuan[i]);
                    contentMap[CutClass(datas.name[i])].content.name.push(datas.name[i],);
                    contentMap[CutClass(datas.name[i])].content.zuozhe.push(datas.zuozhe[i]);
                    contentMap[CutClass(datas.name[i])].content.photo1.push(datas.photo1[i]);
                }
            }
        }
        setContentMap(contentMap);
    }, [datas])
    return <ScrollView style={styles.Vessels}>
        {contentMaps.map((item, index) => {
            return (
                <View key={index}>
                    {item.content.laiyuan.length !== 0 && <NewHeader navigation={navigation} msg={item} />}
                </View>
            );
        })}
    </ScrollView>
}

const styles = StyleSheet.create({
    Vessels: {
        width: '100%',
        height: '100%',
        padding: 20,
        backgroundColor: '#fff',
    },
    header: {
        marginBottom: 10,
    },
});